function selectStocks() {
    var factoryId = $("#factoryId").val();
    if(factoryId && factoryId != ""){
        var postData="factoryId=" + factoryId;
        $.ajax({
            type: "GET",
            url: "${ctx}/basic/stock/getStockInfoByFactoryId",
            data: postData,
            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
            async: true, // 同步  true 异步。默认是异步
            dataType: 'json',
            error: function(resultdata) {

            },
            success: function(resultdata) {
                if(resultdata.returnCode=="0000"){
                    document.getElementById("stockId").options.length = 0;
                    var options = "<option value='' >全部</option>";
                    for (var i = 0 ; i < resultdata.items.length; i++ ) {
                        options += "<option value='" + resultdata.items[i].id+ "'>" +resultdata.items[i].stockName  + "</option>";
                    }
                    $(options).appendTo($("#stockId"));
                }else{
                    layer.alert(resultdata.returnMessage);
                }
            }
        });
    }else{
        document.getElementById("stockId").options.length = 0;
        var options = "<option value='' >全部</option>";
        $(options).appendTo($("#stockId"));
    }
}